package com.eduService.teacher.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.eduService.teacher.entity.EduTeacher;
import com.eduService.teacher.mapper.EduTeacherMapper;
import com.eduService.teacher.service.IEduTeacherService;
import com.eduService.teacher.vo.teacherConditionVo;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 讲师 服务实现类
 * </p>
 *
 * @author Tangcow
 * @since 2022-03-26
 */
@Service
public class EduTeacherServiceImpl extends ServiceImpl<EduTeacherMapper, EduTeacher> implements IEduTeacherService {

    @Override
    public void pageQuery(Page<EduTeacher> pageParam, teacherConditionVo teacherVo) {

        QueryWrapper<EduTeacher> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByAsc("sort");
        if (teacherVo == null){
            baseMapper.selectPage(pageParam,queryWrapper);
            return ;
        }
//            获取对象各值
        String tname = teacherVo.getName();
        System.out.println(tname);
        Integer level = teacherVo.getLevel();
        System.out.println(level);
        String begin = teacherVo.getBegin();
        String over = teacherVo.getOver();
//          判断各值是否为空，不为空就添加到模糊查询条件中
        if (!StringUtils.isEmpty(tname))queryWrapper.like("name",tname);
        //eq相当于“=”
        if (level != null)queryWrapper.eq("level",level);
        //ge相当于“>=”
        if (!StringUtils.isEmpty(begin))queryWrapper.ge("gmt_create",begin);
        //le相当于“<=”
        if (!StringUtils.isEmpty(over))queryWrapper.le("gmt_modified",over);
//          根据嵌入条件进行分页查询
        baseMapper.selectPage(pageParam,queryWrapper);
    }
}
